﻿<?php

	if(!empty($_POST)){
		require_once("../config/config.php");

		$nom    = $_POST["nom"];
		$prenom = $_POST["prenom"];
		$mail   = $_POST["mail"];
		$statut = $_POST["statut"];
		$banque = $_POST["banque"];
		$agence = $_POST["agence"];  
		$compte = $_POST["compte"];
		$cle    = $_POST["cle"];
		
		//connexion à la base de donnée via PDO
		$db = new PDO(PDO_DSN, USER , PASSWD ) or die("échec de connexion au serveur");
		$db->exec("SET NAMES 'UTF8'");
		
		if($banque == "") $banque = "null";
		if($agence == "") $agence = "null";
		if($compte == "") $compte = "null";
		if($cle    == "") $cle    = "null";
		
		$sql = "
			update clients
			set cl_nom = '$nom',
				cl_prenom = '$prenom',
				cl_mail = '$mail',
				cli_status = '$statut',
				rib_banque = $banque,
				rib_agence = $agence,
				rib_cpte = $compte,
				rib_cle = $cle
			where cl_id = " . $_GET['client'];
		
		$rq = $db->prepare($sql);
		$rq->execute();
	} 
	
	header("location: ../pages/listeClients.php");
?>